package com.sms.web.domain.controller;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.sms.core.service.ExceptionProcesser;
import com.sms.core.service.ExceptionProcesser.ExceptionRecorder;

/**
 * @desc 异常控制器
 * @author WuJiangWu
 * @date 2018年7月21日上午1:14:53
 */
@Controller
@RequestMapping(value = "/sms")
public class SmsExceptionController {
    
    protected static Logger logger = LoggerFactory.getLogger(SmsExceptionController.class);
    
    @Autowired
    private ExceptionProcesser exceptionProcesser;
    
    /**
     * 配置信息列表
     * @param model
     * @return
     */
    @RequestMapping(value = "/exception")
    public String pageList(ModelMap model) {
        List<ExceptionRecorder> list = new ArrayList<>();
        Collection<ExceptionRecorder> exs = exceptionProcesser.getExceptions();
        for (ExceptionRecorder ex : exs) {
            list.add(0, ex);
        }
        model.put("list", list);
        return "exception/list";
    }
    
}
